const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const cors = require('@koa/cors');
const views = require('./Views/index.js');

const app = new Koa();

// 使用 bodyParser 中间件来解析请求体
app.use(bodyParser());

// 跨域设置
app.use(cors());

for (const view in views) {
  app.use(views[view].routes());
  app.use(views[view].allowedMethods());
}


const port = process.env.PORT || 8000;

app.listen(port, () => {
  console.log(`Server running at http://localhost:${port}/`);
})